package com.fy.repo.mapper;

import com.fy.repo.entity.Repo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 题库 Mapper 接口
 * </p>
 *
 * @author bjt
 * @since 2023-06-12
 */
public interface RepoMapper extends BaseMapper<Repo> {
    @Update("UPDATE el_repo r\n" +
            "SET r.radio_count = (SELECT COUNT(*) FROM el_qu_repo WHERE el_qu_repo.repo_id=#{repoId} AND el_qu_repo.qu_type = 1),\n" +
            "r.multi_count = (SELECT COUNT(*) FROM el_qu_repo WHERE el_qu_repo.repo_id=#{repoId} AND el_qu_repo.qu_type = 2),\n" +
            "r.judge_count = (SELECT COUNT(*) FROM el_qu_repo WHERE el_qu_repo.repo_id=#{repoId} AND el_qu_repo.qu_type = 3),\n" +
            "r.jdt_count = (SELECT COUNT(*) FROM el_qu_repo WHERE el_qu_repo.repo_id=#{repoId} AND el_qu_repo.qu_type = 4)\n" +
            "WHERE r.id = #{repoId}")
    public int updateCountByRepoId(String repoId);
}
